import plugin from '../../../lib/plugins/plugin.js';
import fs from 'fs';
import puppeteer from "../../../lib/puppeteer/puppeteer.js";
import { getCurrentTime } from "../model/getCurrentTime.js";
import { parse } from 'yaml';
import axios from "axios"

//定义配置路径
const yamlPathSign = new URL('../config/signin.yaml', import.meta.url).pathname;
const yamlPathKey= new  URL('../config/Rediskey.yaml', import.meta.url).pathname;


export class AIhub_sign extends plugin {
    /**
     * 构造函数，初始化插件的基本信息
     */
    constructor() {
        super({
            name: '签到',
            dsc: '',
            event: 'message',
            priority: 2000,
            rule: [
                {
                    reg: '^#签到$',
                    fnc: 'Signin'
                },
                {
                    reg: '^#已签到统计$',
                    fnc: 'Statistics'
                },
                {
                    reg: '^#(开启|关闭)签到',
                    fnc: "Switch"
                },
                {
                    reg: "^#修改签到经验(.*)",
                    fnc: "Experience"
                },
                {
                    reg: "^#(开启|关闭)签到倍率",
                    fnc: "Magnification"
                },
                {
                    reg: "^#修改签到倍率(.*)",
                    fnc: "Modify"
                }
            ]
        })
    }
    
    //签到实现方法
    async Signin (e) {
        //获取当前时间天
        let date = await getCurrentTime('date')
        //获取时间
        let time = await getCurrentTime('time')
        let key = yamlReader.get("PersonalData")
        let UserData = await redis.get(`${key}${e.user_id}`)
        if(!UserData) { //用户数据为空时创建数据
            await redis.set(`${key}${e.user_id}`, JSON.stringify(data))
        }
        
        //判断今日是否签到
        
    }
}